package stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 实现集合元素去重
 */
public class Distinct {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList();
        list.add("A");
        list.add("A");
        list.add("B");
        list.add("A");
        List<String> collect = list.stream().distinct().collect(Collectors.toList());
        collect.forEach(k -> {
            System.out.println(String.format("Element=%s",k));
        });
    }

}
